package com.coolcode.util;

import com.coolcode.entity.LoginUserInfo;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.context.SecurityContextHolder;

public class SecurityContextUtil {

    public static LoginUserInfo getLoginUserInfo() {
        UsernamePasswordAuthenticationToken authentication = (UsernamePasswordAuthenticationToken) SecurityContextHolder.getContext().getAuthentication();
        return (LoginUserInfo)authentication.getPrincipal();
    }
}
